package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.bo.StorageDeleteBo;
import com.cskaoyan.bean.bo.StorageUpdateBo;
import com.cskaoyan.bean.param.BaseParam;
import com.cskaoyan.bean.po.StoragePO;
import com.cskaoyan.bean.vo.StorageListVO;
import com.cskaoyan.bean.vo.StorageUpdateVo;
import com.cskaoyan.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("admin/storage")
public class StorageController {
    @Autowired
    StorageService storageService;

    /**
     * 实现/admin/storage/list 接口
     * chy 2022年06月06日21:19:33
     * @param baseParam
     * @param key
     * @param name
     * @return
     */
    @RequestMapping("list")
    public BaseRespVo list(BaseParam baseParam, String key, String name){
    StorageListVO storageListVO =  storageService.list(baseParam, key, name);
        // return
        return  BaseRespVo.ok(storageListVO);

    }

    /**
     * 实现/admin/storage/update接口
     * @param StorageUpdateBo
     * @return
     */
    @RequestMapping("update")
    public BaseRespVo  update(@RequestBody StorageUpdateBo StorageUpdateBo){
       StorageUpdateBo storageUpdateBo =   storageService.update(StorageUpdateBo);
       return BaseRespVo.ok(storageUpdateBo);
    }

    /**
     *
     * @param storageDeleteBo
     * @return
     */
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody StorageDeleteBo storageDeleteBo){
        storageService.delete(storageDeleteBo);
        return BaseRespVo.ok(null);

    }
    @RequestMapping("create")
    public BaseRespVo create(MultipartFile file){
        return storageService.create(file);
    }



}
